"""
@File    : object_oriented_programming_catClass.py
@Author  : WorldWind(1772830365@qq.com)
@Time    : 2025/7/11
"""

class Cat:
    # 属性
    color = 'blue'
    height = 30
    age = 2

    # 构造方法(初始化方法),在创建对象的时候python自动调用的方法
    def __init__(self,color,height,age):
        self.color = color
        self.height = height
        self.age = age
        self.introduceMyself()
        print('--- init Method Be invoked ---')

    # 析构方法(对象销毁时候自动调用)
    def __del__(self):
        print('--- del Method Be invoked ---')

    def introduceMyself(self):
        print(self.height,self.age,self.color)
    # 行为
    def talk(self,name):
        return f'miaomiaomiao {name} ~~~ --- Common method'

    def eat(self,cat):
        print(cat)
        print(cat.jump())
        return 'Eat cat food --- Common method'

    # 类的静态方法
    @staticmethod
    def run():
        return 'Start running! --- static method'

    # 类方法 想调用类本身的方法或属性,用此方法
    @classmethod
    def jump(cls):
        print(cls.age)
        return 'The cat is jumping! --- class method'


# print(Cat.run())
# cat = Cat()
# print(cat.talk(12))
# print(Cat.color + ' --- The attributes of cats')
# print(str(Cat.age) + ' --- The attributes of cats')
# print(str(Cat.height) + ' --- The attributes of cats')
# print(Cat.jump())

# 通过类,创建对象 , __init__方法会被自动调用
# c1 = Cat('red',20,1)
# print(c1.jump())
# print(c1.run())
# print(c1.age)
# print(Cat.age)
# print(c1.height)
# print(c1.color)
# print(c1.eat(c1))

# c2 = Cat('white',20,3)
# c3 = Cat('red',18,5)

c2 = Cat('red',10,1)
c2.introduceMyself()
